package com.xzl.shop.server;

import com.xzl.shop.dao.IGoods2Dao;
import com.xzl.shop.model.Goods2;
import com.xzl.shop.model.GoodsType2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class Goods2Server {
    @Autowired
    private IGoods2Dao goodsDao;
    public List<Goods2> selectGoods(Goods2 good){
        List<Goods2> list = goodsDao.selectGoods(good);
        return list;
    }
    public List<Goods2> selectGoodsOnSale(Goods2 good){
        List<Goods2> list = goodsDao.selectGoodsOnSale(good);
        return list;
    }
    public List<Goods2> selectGoodsNoSale(Goods2 good){
        List<Goods2> list = goodsDao.selectGoodsNoSale(good);
        return list;
    }
    public List<GoodsType2> selectTypes(){
        return goodsDao.selectTypes();
    }

    public Integer insertGoods(Goods2 g){
        if(g!=null) return goodsDao.insertGoods(g);
        else return 0;
    }
    public Integer updateGoods(Goods2 g){
        if(g!=null) return goodsDao.updateGoods(g);
        else return 0;
    }
    public Integer downGoods(String ids){
        if(ids != null && !ids.isEmpty()){
            String[] id = ids.split(",");
            return goodsDao.downGoods(id);
        }
        return 0;
    }
    public Integer upGoods(String ids){
        if(ids != null && !ids.isEmpty()){
            String[] id = ids.split(",");
            return goodsDao.upGoods(id);
        }
        return 0;
    }
    public List<Goods2> queryNew(){
        return goodsDao.queryNew();
    }
}
